
const { update } = require("../constroller/UserController.js")
const userModel = require("../model/UserModel.js")



const userService = {
    login: (username, password) => {
        return userModel.find({ "username": username, "password": password })
    },
    register: (username, password, email) => {
        return userModel.insertOne({ username, password, email })
    },
    findUserNmae: (username) => {
        return userModel.find({ "username": username })
    },
    add: (username, password, email, image) => {
        return userModel.insertOne({ username, password, email, image })
    },
    update: (id, username, password, email) => {
        return userModel.updateOne({ _id: id }, { $set: { username, password, email } })
    },
    delete: (id) => {
        return userModel.deleteOne({ _id: id })
    }
    ,
    users: () => {
        return userModel.find({})
    }

}

module.exports = userService